package com.gem.netty.service.gem;

import com.gem.enums.ClientMessageType;
import com.gem.enums.MessageColorType;
import com.gem.netty.entity.ClientContent;
import com.gem.netty.entity.Content;
import com.gem.pipeline.BusinessProcess;
import com.gem.pipeline.ProcessContext;
import com.gem.utils.R;

/**
 * Author: Xhy
 * CreateTime: 2022-10-02 14:58
 * 校验拿宝石格式
 */
public class GetGemVerifyService implements BusinessProcess<ClientContent> {

    @Override
    public void process(ProcessContext<ClientContent> context) {

        Content content = context.getData().getContent();
        Integer gem = content.getGem();
        // 是否为空 是否宝石类型非法
        if (gem == null || (gem < 0 && gem > 6)){
            context.setResult(R.error().data("color", MessageColorType.SYSTEM_MESSAGE.type).message("非法操作").type(ClientMessageType.GET_GEM.type));
            context.setNeedBreak(true);
        }
    }
}
